// function * foo(){
//   console.log(111)
//   yield 100
//   console.log(222)
//   yield 200
//   console.log(333)
//   yield 300
// }
// const generator = foo()
// console.log(generator.next()) //{ value: 100, done: false }
// console.log(generator.next()) //{ value: 200, done: false }
// console.log(generator.next()) //{ value: 300, done: false }
// console.log(generator.next()) //{ value: undefined, done: true }
// 利用generator实现id自增
// function * idMarker(){
//   let id = 0
//   while(true) {
//     yield id ++
//   }
// }
// const marker = idMarker()
// console.log(marker.next().value)
// console.log(marker.next().value)
// console.log(marker.next().value)
// console.log(marker.next().value)
const obj = {
  front: ['js','html','css'],
  back: ['java','php','c#'],
  //增加迭代器函数
  [Symbol.iterator]: function *(){
    const arr = [...this.front,...this.back]
    for(let item of arr) {
        yield item
    }
  }
}
for(let item of obj) {
  console.log(item)
}